<%@ page import="cn.java71.service.StudentService" %>
<%@ page import="cn.java71.entity.Student" %>
<%@ page import="cn.java71.service.GradeService" %>
<%@ page import="cn.java71.entity.Grade" %>
<%@ page import="java.util.List" %>
<%@ page import="cn.java71.util.StrUtil" %><%--
  Created by IntelliJ IDEA.
  User: oldliu
  Date: 2021/1/28
  Time: 14:17
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>修改学生信息</title>
    <script src="js/jquery-3.4.1.min.js"></script>
</head>
<body>
 <%
     long stuno=Long.parseLong(request.getParameter("stuno"));
     StudentService studentService=new StudentService();
     Student stu=studentService.get(stuno);
     out.print(stu);
     if(stu==null){
         out.print("<script>alert('此对象已经不在了');history.back();</script>");
         return;
     }
 %>
 <jsp:include page="checkLogin.jsp"/>
<form action="doUpdate.jsp" method="post">
    <p>
       姓名 <input type="text" name="sname" value="<%=stu.getSname()%>"/>
    </p>
    <p>
        <%--<%=stu.getSex()%>
        <%if(stu.getSex().equals("男"))out.print("checked");%>--%>
        性别:<input type="radio" name="sex" value="男" />男
            <input type="radio" name="sex"  value="女" />女
            <input type="radio" name="sex"  value="妖" />妖
            <input type="radio" name="sex"  value="人妖" />人妖
    </p>
    <p>
        年级:
        <select name="gradeid">
        <%
            GradeService gs=new GradeService();
            List<Grade> all = gs.findALL();
            for(Grade g:all){

        %>
            <option <%if(g.getId()==stu.getGradeid())out.print("selected");%>  value="<%=g.getId()%>"><%=g.getGname()%></option>
            <%}%>
        </select>
    </p>
    <p>入学日期:<input type="date" value="<%=StrUtil.toStr(stu.getEnterdate())%>"/> </p>
    <p>
        <input type="submit"/>
    </p>
</form>

<script>
    $(function () {
        $(":radio[name=sex][value=<%=stu.getSex()%>]").prop("checked",true);
        //alert(44);
        //$(":radio[name=sex]").val('<%=stu.getSex()%>');
    });
</script>
</body>
</html>
